package org.qqcui.designpattern.patterns.iterator;

import java.util.Iterator;
import java.util.List;

/**
 * 信息学院迭代器
 *
 * @author cuiqingqiang
 * @version 1.0
 * @date 2022/5/6 14:16
 **/
public class InfoCollegeIterator implements Iterator<Department> {

    /**
     * 信息学院下的专业，是以list数据结构存储的
     */
    private List<Department> departments;

    /**
     * list集合的下标
     */
    private int index = -1;

    public InfoCollegeIterator(List<Department> departments) {
        this.departments = departments;
    }

    @Override
    public boolean hasNext() {
        if (index >= departments.size() - 1) {
            return false;
        } else {
            return true;
        }
    }

    @Override
    public Department next() {
        Department department = departments.get(++index);
        return department;
    }

    @Override
    public void remove() {

    }
}
